package org.jeecg.common.modules.doctor.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.jeecg.common.modules.doctor.entity.DoctorAccount;
import org.jeecg.common.modules.doctor.vo.DoctorAccountInfoReqVo;

import java.math.BigDecimal;
import java.util.List;

/**
 * @Description: doctor_account
 * @Author: jeecg-boot
 * @Date:   2020-08-22
 * @Version: V1.0
 */
public interface DoctorAccountMapper extends BaseMapper<DoctorAccount> {
    /**
     * 医生、医生账户联查mapper的声明
     * @param name
     * @param dataStart
     * @param pageSize
     * @return
     */
    List<DoctorAccountInfoReqVo> selectDoctorAccountInfo(
            @Param("name") String name,
            @Param("dataStart")Integer dataStart,
            @Param("pageSize")Integer pageSize);

    /**
     * 医生、医生账户联查的总条数
     * @param name
     * @return
     */
    int getDoctorAccountCount(String name);


    /**
     * 修改医生余额
     * @param id            账户表主键
     * @param amount        余额
     * @param totalAmount   累计收入
     */
    @Update("update doctor_account set balance = balance + #{amount}, total_amount = total_amount + #{totalAmount} where id = #{id}")
    void changeBalance(@Param("id") String id, @Param("amount")BigDecimal amount,@Param("totalAmount") BigDecimal totalAmount);
}
